package Server;

import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;

public class Server
    {

    /**
     * @param args
     */
    public static void main( String[] args )
        {
        ORB orb = ORB.init(args, null);
        BibliotekaImpl bi;
        try
            {
            bi = new BibliotekaImpl( new PolaczenieMSSQL2005());
        
            POA rootpoa;
            POA child1;

            rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
            child1 = rootpoa.create_POA("ChildPOA1", null, null);
            child1.activate_object(bi);
            
            org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
            NamingContextExt nc = NamingContextExtHelper.narrow(objRef);
            NameComponent path1[] = nc.to_name( "BibliotekaObject");
            
            nc.rebind(path1, child1.servant_to_reference(bi));
            
            child1.the_POAManager().activate();
            System.out.println( "Serwer oczekuje...");
            orb.run();
            
            }
        catch( Exception e )
            {
            e.printStackTrace( System.out );
            }

        }

    }
